<html>
<script>
/*
const toSlug = input => encodeURIComponent(
  input.split(' ')
    .map(str => str.toLowerCase())
    .join('-')
);
*/
const underScore = input => (
	input.split(' ')
    .map(str => str.toLowerCase())
    .join('-')
)
;

// Jerry 2017-02-23 3:55PM wraped with { } will not work any more
const toUpper = input => input.toUpperCase();
const toSlug = input => encodeURIComponent(
  // debugger; Uncaught SyntaxError: Unexpected token debugger
  /*var a1 = input.split(' ');
  var a2 = a1.map(str => str.toLowerCase());
  var a3 = a2.join('-');
  a3;*/
  toUpper(underScore(input)) // ; semi-colon sensitive!!!!
);

console.log(toSlug("Jerry Wang"));
// toSlug = "1"; // runtime error: assignment to constant variable
console.log(typeof toSlug); // function

function a(a1, a2){

};
// a.length = 2 -> number of argument
debugger;
// Jerry 2017-02-23 15:45PM .. will not work
const curry = fn => (...argsFuck) => fn.bind(null, ...argsFuck);
/* Jerry 2017-02-23 3:31PM - fn is argument one, ...args is argument two, three, four?? 

length of curry.length: 1
*/

function JerryUpper(...arg){
	console.log("Jerry's upper: " + arg);
}
const vartest = (...ar) => console.log(...ar); // this will work

const vartest2 = fn => (...arg2) => fn(...arg2); 
console.log("new challenge comes");
vartest("jerry", "wang");
console.log("new challenge comes again");
var newFunction = vartest2(JerryUpper);

newFunction("Rocks", "Scala"); //消元的思想
const map = curry((fn, arr) => arr.map(fn));


</script>
</html>